package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from sky_take_out.dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    @AutoFill(OperationType.INSERT)
    Long addDish(Dish dish);

    /**
     * 根据分类，名称和状态查询所有对应菜品
     * @param dish
     * @return
     */
    List<DishVO> query(Dish dish);

    void deleteAll(List<Long> ids);

    int checkStatus(List<Long> ids);

    @Select("select * from sky_take_out.dish where id = #{id}")
    Dish queryById(Long id);

    void updateDish(Dish dish);

    @Select("select * from sky_take_out.dish where dish.category_id = #{categoryId}")
    List<Dish> queryByCategoryId(Integer categoryId);
}
